JavaScript Tutorials - Herong's Tutorial Examples - 2.33, by Herong Yang
Global Properties and Functions Defined in ECMAScript
This section provides a quick description of all global properties and functions mentioned in the ECMAScript specification.
There 3 built-in global properties with primitive values contained in the invisible "Global" object mentioned in the ECMAScript specification:
There are 9 regular built-in global functions contained in the invisible "Global" object mentioned in the ECMAScript specification:
There are 9 special built-in global functions contained in the invisible "Global" object mentioned in the ECMAScript specification. These functions are really constructors of built-in object types:
There 1 built-in global properties with an object value contained in the invisible "Global" object mentioned in the ECMAScript specification:
In order to verify those global properties and functions, I wrote this simple script:
// Global_Object_Properties.js // Copyright (c) 2013 HerongYang.com. All Rights Reserved. println("\nGlobal primitive-value properties:"); println(" NaN: Type = "+(typeof this.NaN) + ", Value = "+this.NaN); println(" Infinity: Type = "+(typeof this.Infinity) + ", Value: "+this.Infinity); println(" undefined: Type = "+(typeof this.undefined) + ", Value = "+this.undefined); println("\nGlobal functions:"); println(" eval: Value = "+this.eval); println(" parseInt: Value = "+this.parseInt); println(" parseFloat: Value = "+this.parseFloat); println(" isNaN: Value = "+this.isNaN); println(" isFinite: Value = "+this.isFinite); println(" decodeURI: Value = "+this.decodeURI); println(" decodeURIComponent: Value = "+this.decodeURIComponent); println(" encodeURI: Value = "+this.encodeURI); println(" encodeURIComponent: Value = "+this.encodeURIComponent); println("\nGlobal constructors:"); println(" Object: Value = "+this.Object); println(" Function: Value = "+this.Function); println(" Array: Value = "+this.Array); println(" String: Value = "+this.String); println(" Boolean: Value = "+this.Boolean); println(" Number: Value = "+this.Number); println(" Date: Value = "+this.Object); println(" RegExp: Value = "+this.RegExp); println(" Error: Value = "+this.Error); println("\nGlobal object-value property:"); println(" Math: Type = "+(typeof this.Math) + ", Value = "+this.Math);
If you run this script with "jrunscript", you will get:
Global primitive-value properties: NaN: Type = number, Value = NaN Infinity: Type = number, Value: Infinity undefined: Type = undefined, Value = undefined Global functions: eval: Value = function eval() { [native code parseInt: Value = function parseInt() { [native code parseFloat: Value = function parseFloat() { [native code isNaN: Value = function isNaN() { [native code isFinite: Value = function isFinite() { [native code decodeURI: Value = function decodeURI() { [native code decodeURIComponent: Value = function decodeURIComponent() { [native encodeURI: Value = function encodeURI() { [native code encodeURIComponent: Value = function encodeURIComponent() { [native Global constructors: Object: Value = function Object() { [native code Function: Value = function Function() { [native code Array: Value = function Array() { [native code String: Value = function String() { [native code Boolean: Value = function Boolean() { [native code Number: Value = function Number() { [native code Date: Value = function Object() { [native code RegExp: Value = function RegExp() { [native code Error: Value = function Error() { [native code Global object-value property: Math: Type = object, Value = [object Math]
This confirms that the "jrunscript" does support all global properties and functions mentioned in the ECMAScript specification.
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
Data Types, Variables and Expressions
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
Web Browser Supporting JavaScript
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
►Introduction to Built-in Object Types
Overview of Built-in Object Types
The "Object" Object Type - The Root Object Type
The "Global" Object Type - The Invisible Global Container
►Global Properties and Functions Defined in ECMAScript
Global Properties and Functions Provided by "jrunscript"
The "Function" Object Type - Functions Are Objects
The "Array" Object Type - Arrays Are Objects
The "JSON" Object Type - parse() and stringify()
The "String" Object Type - Not Equal to String Primitive Type
The "Boolean" Object Type - Wrapping Boolean Values into Objects
The "Number" Object Type - Not Equal to Number Primitive Type
The "Date" Object Type - Managing Dates and Times
The "RegExp" Object Type - Regular Expression Patterns
The "Error" Object Type - Runtime Exceptions
The "Math" Object Type - The Math Container
W3C's Document Object Model (DOM) Specifications